package cn.git.shiro.util;

import cn.hutool.crypto.digest.BCrypt;
import org.springframework.stereotype.Component;

/**
 * @description: hutool密码工具类
 * @program: bank-credit-sy
 * @author: lixuchun
 * @create: 2024-03-27
 */
@Component
public class PassUtil {

    /**
     * 获取加密密码
     *
     * @param password
     * @return
     */
    public String getPassHash(String password) {
        return BCrypt.hashpw(password, BCrypt.gensalt());
    }

    /**
     * 验证密码
     *
     * @param password 前端加密密码
     * @param dbPassword 数据库查询用户密码
     * @return
     */
    public boolean checkPass(String password, String dbPassword) {
        return BCrypt.checkpw(password, dbPassword);
    }
}
